/**
 * Created by Administrator on 2018/10/24.
 */
var spaceCondition = {
  html: function (regionArray) {
    var type = {
        // CitySpatialWay: '按市',
        // ProvinceSpatialWay:'按省',
        // CountySpatialWay:'按区县',
        // RiverBasinWay:'流域',
        // RegionWay:'区域',

        SingleStationWay: '具体站',
        // StationSpatialWay: '所有站'
      },
      region = {
        // RegionArea: '区域面积',
        // RegionCount: '区域总数',
        // RegionSum: '区域累计',
        RegionAvg: '区域平均值',
        RegionMax: '区域最大值',
        RegionMin: '区域最小值'
      },
      html = '<div class="pluginsDiv layui-form-item"  style="display: none" id="spaceCondition">';


    var typeOption = '';
    for ( var ty in type ) {
      typeOption += '<option value="'+ ty +'">'+ type[ty] +'</option>';
    }
      html += '<div class="layui-form-item pluginsSingleRows">' +
        '<label class="layui-form-label">空间类型:</label>' +
        '<div class="layui-input-block">' +
          '<select lay-filter="spaceTypeSelect" id="spaceTypeSelect" >'+ typeOption +'</select>' +
        '</div>' +
      '</div>';


    var regionOption = '';
    for ( var i = 0, len = regionArray.length; i < len; i++ ) {
      regionOption += '<option value="'+ regionArray[i] +'">'+ region[regionArray[i]] +'</option>';
    }
    html += '<div style="display: none;" class="layui-form-item static-condition pluginsSingleRows">' +
      '<label class="layui-form-label">统计条件:</label>' +
      '<div class="layui-input-block">' +
        '<select data-disabled="true" id="spaceStaticSelect" class="layui-input-disabled" >'+ regionOption +'</select>' +
      '</div>' +
    '</div>';


    html += '</div>';
    return html;
  },
  getData: function () {
	  
    Global.postData.spatialStaticsWay = $('#spaceTypeSelect').val();
    Global.postData.regValueType = $('#spaceStaticSelect').val();

    /*如果空间类型时是 具体站 默认不勾选，为RegionSum*/
    if(Global.postData.spatialStaticsWay === 'SingleStationWay'){
    	Global.postData.regValueType="RegionSum";
    }

  },
  renderCallback: function () {
    layForm.on('select(spaceTypeSelect)', function (data) {
      if ( data.value === 'SingleStationWay' ) {
        $('#spaceCondition').find('.static-condition').hide().find('.static-condition-select').attr('data-disabled', 'true');

          initControlByName(data.value);
      } else {
        $('#spaceCondition').find('.static-condition').show().find('.static-condition-select').attr('data-disabled', 'false');

          // $('#historyPluginsDiv .multiOption').eq(1).click();//当为所有站清空 历史统计机的全部
      }
    });
  }
};